import React, { Component } from 'react';

// 其他表单中的受控表单也是类似的用法 多行文本框

class App extends Component {
  state = {
    val:'输入内容'
  }
  handleSubmit = () => {
    console.log('提交',this.state.val)
  }
  handleChange = (e) => {
    console.log(e.target.value);  //输入框输入的内容
    this.setState({
      val:e.target.value  
    })
  }
  render() {
    return (
      <div>
        <input type="text" value={this.state.val} onChange={this.handleChange}/>
        <button onClick={this.handleSubmit}>提交</button>


      </div>
    );
  }
}

export default App;
